﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JCTimes.DomainModel.Repository;
using JCTimes.DomainModel.Entity;

namespace JCTimes.EFRepository.RepositoryImpl
{
    public class PDAFunctionsRepository : BaseRepository<PDAFunction>, IPDAFunctionsRepository
    {
        /// <summary>
        /// Confirm whether the function is authorized to the role or not.
        /// </summary>
        /// <param name="roleID">role id</param>
        /// <param name="functionID">function id</param>
        /// <returns>true if the function has been authorized</returns>
        public bool IsMatch(string usersID, string PADFunctionID)
        {
            return db.PDAUsersFunction.Any(fr => fr.UsersID == usersID && fr.PDAFunctionID == PADFunctionID);
        }

        public bool IsPDAMatch(string pdaid, string PADFunctionID)
        {
            return db.PDAPDAFunction.Any(fr => fr.PDAID == pdaid && fr.PDAFunctionID == PADFunctionID);
        }
    }
}
